package main;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
import java.io.InputStream;

public class Main extends MIDlet implements CommandListener{
    private SSGameCanvas gameCanvas ;
    private Command exitCommand ;
  
    public void startApp() {
        try {
            //create new game thread
            gameCanvas = new SSGameCanvas();
            gameCanvas.start(); // start game thread
            exitCommand = new Command("Exit",Command.EXIT,1);
            gameCanvas.addCommand(exitCommand);
            gameCanvas.setCommandListener(this);
            Display.getDisplay(this).setCurrent(gameCanvas);
        }
        catch (java.io.IOException e) { e.printStackTrace();}

    }


    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        System.gc();
    }

    public void commandAction(Command command, Displayable displayable) {
        if (command == exitCommand) {
            destroyApp(true);
            notifyDestroyed();
        }
    }
}
